<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>用户登录</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>" />
  <link rel="stylesheet" href="<?php echo e(url('/')); ?>/bootstrap/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="<?php echo e(url('/')); ?>/libs/font-awesome/4.5.0/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="<?php echo e(url('/')); ?>/libs/ionicons/2.0.1/css/ionicons.min.css">
  <link rel="stylesheet" href="<?php echo e(url('/')); ?>/dist/css/AdminLTE.css">
  <link rel="stylesheet" href="<?php echo e(url('/')); ?>/plugins/iCheck/square/blue.css">
  <script src="<?php echo e(url('/')); ?>/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="<?php echo e(url('/')); ?>/libs/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>
<body class="hold-transition login-page">
<div class="login-box">
  <div class="login-logo">
    <a><b>共享图书后台管理</b></a>
  </div>
  <!-- /.login-logo -->
  <div class="login-box-body">
    <p class="login-box-msg">感创科技</p>

    <form id="validate" class="form">
      <div class="form-group has-feedback">
        <input type="text" class="form-control" placeholder="登录名"  name="name" value="<?php echo e(old('name')); ?>">
        <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
      </div>
      <div class="form-group has-feedback">
        <input type="password" class="form-control"  name="password" placeholder="密码">
        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
      </div>
      <div class="row">
        <div class="col-xs-8">
          <div class="checkbox icheck">
            <label>
              <input type="checkbox"> 记住登录
            </label>
          </div>
        </div>
        <!-- /.col -->
        <div class="col-xs-4">
          <button type="submit" class="btn btn-primary btn-block btn-flat">登录</button>
        </div>
        <!-- /.col -->
      </div>
    </form>
  </div>
  <!-- /.login-box-body -->
</div>
<!-- /.login-box -->

<!-- jQuery 2.2.0 -->
<script src="<?php echo e(url('/')); ?>/plugins/jQuery/jQuery-2.2.0.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="<?php echo e(url('/')); ?>/bootstrap/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="<?php echo e(url('/')); ?>/plugins/iCheck/icheck.min.js"></script>
<script type="text/javascript" src="<?php echo e(url('plugins/layer/layer.js')); ?>"></script>
<script>
  $(function () {
    $('input').iCheck({
      checkboxClass: 'icheckbox_square-blue',
      radioClass: 'iradio_square-blue',
      increaseArea: '20%' // optional
    });
  });
</script>
<script type="text/javascript">
  $.ajaxSetup({
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
  });

  $(function(){
    var load;
    $('.btn-flat').on('click',function(e){
      e.stopPropagation();
      e.preventDefault();

      var data = $('.form').serialize();
      $.ajax({
        url:"<?php echo e(url('admin/postLogin')); ?>",
        type:'post',
        data:data,
        beforeSend:function(){
          load = layer.load(1, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
          });
        },
        success:function(data){
          layer.close(load);
          if(data.success){
            layer.msg(data.msg);
            setTimeout(function(){location.href = '<?php echo e(url('back')); ?>';},500);
          }
          else{
            layer.msg(data.msg,{icon: 5});
          }
        },
        error: function () {
          layer.msg('请求出错，请重新登录');
        }
      });
    });
  });
</script>
</body>
</html>
